/**
 * @file 呼叫下单
 * @author yangjiangming <449654337@qq.com>
 * @date 2019/04/23 16:17
 */

layui
  .extend({
    oms_work_config: "work/config/zmn.oms.work.config",
    mos_order_add_common: "order/zmn.mos.order.add.common"
  })
  .define(
    [
      "oms_work_config",
      "mos_order_add_common",
      "zmnUtils",
      "layer",
      "form",
      "$http",
      "table"
    ],
    function (exports) {
      var addUtils = layui.mos_order_add_common;
      var config = layui.oms_work_config;
      var zmnUtils = layui.zmnUtils;
      var config = layui.oms_work_config;
      var $http = layui.$http;
      var layer = layui.layer;

      // 获取真是手机号路径
      var GET_REAL_PHONE_URL = "/order/normal/getRealPhone";

      /**
       * 初始化页面
       */
      function initPage() {
        // 初始化页面
          addUtils.init({
              isNew: true,
              isDistributeMaster: true,
              saveURL: config.url.saveShoppingCartURL,
              success: function (data) {
                  if (!data.orderWork.workId) {
                      data.orderWork.workId = 0;
                  }
                  parent.postMessage(
                      {
                          callId: zmnUtils.getQueryString("callId"),
                          recordsDelegateKey: zmnUtils.getQueryString(
                              "recordsDelegateKey"
                          ),
                          type: 1,
                          code: 200,
                          data: data,
                          message: "订单保存成功",
                      },
                      "*"
                  );

                  addUtils.goDetail(data.orderWork.orderId, data.orderWork.workId);
              },
          });
      }

      /**
       * 初始化页面事件
       */
      function initEvent() {
        // 物流信息
        // addUtils.renderNewOrderPost();
      }

      function init() {
        // 初始化页面
        initPage();

        // 初始化事件
        initEvent();
      }

      init();
      exports("oms_order_callAdd");
    }
  );
